import { Component, Injector, ViewEncapsulation, ViewChild, ElementRef, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { ReportServiceProxy, ModelListDto, LaunchListDto } from '@shared/service-proxies/service-proxies';
import { AppComponentBase } from '@shared/common/app-component-base';
import { appModuleAnimation } from '@shared/animations/routerTransition';
import { Paginator } from 'primeng/components/paginator/paginator';
import { LazyLoadEvent } from 'primeng/components/common/lazyloadevent';
import { Table } from 'primeng/table';

@Component({
    templateUrl: './chreport.component.html',
    animations: [appModuleAnimation()]
})
export class ChReportComponent extends AppComponentBase implements OnInit {
    @ViewChild('dataTable') dataTable: Table;
    @ViewChild('paginator') paginator: Paginator;
    tabledata;
    selectedDate = new Date();
    constructor(injector: Injector, private _reportService: ReportServiceProxy) {
        super(injector);
    }

    ngOnInit() {
        this.getReport();
    }

    getReport(event?: LazyLoadEvent): void {
        this._reportService
            .getChReportList(this.selectedDate.getFullYear(), this.selectedDate.getMonth() + 1)
            .subscribe(result => {
                this.tabledata = result.items;
            });
    }
}
